package com.jxin.oms.order.domain.inorder.converter;

import com.jxin.oms.order.domain.inorder.dmo.vao.BuyerInfoVao;
import com.jxin.oms.order.web.dto.req.InOrderSaveReqDto;
import org.springframework.util.Assert;

/**
 * @author  Jxin
 * @version 1.0
 * @since   2020-01-20 18:12:35
 */
public class BuyerInfoVaoConverter {
    private BuyerInfoVaoConverter(){}

    /**
     * Convert InOrderSaveReqDto to BuyerInfoVao
     * @param inOrderSaveReqDto 原始单落盘 请求参数
     * @return {@link BuyerInfoVao}
     * @author Jxin
     */
    public static BuyerInfoVao convertToBuyerInfoVao(InOrderSaveReqDto inOrderSaveReqDto) {
        Assert.notNull(inOrderSaveReqDto, "inOrderSaveReqDto不能为null");
        
        final BuyerInfoVao result = new BuyerInfoVao();

        result.setName(inOrderSaveReqDto.getName());
        result.setComment(inOrderSaveReqDto.getComment());
        result.setPhone(inOrderSaveReqDto.getPhone());
        result.setProvince(inOrderSaveReqDto.getProvince());
        result.setCity(inOrderSaveReqDto.getCity());
        result.setArea(inOrderSaveReqDto.getArea());
        result.setStreet(inOrderSaveReqDto.getStreet());
        result.setAddress(inOrderSaveReqDto.getAddress());

        return result;
    }

    /**
     * Convert BuyerInfoVao to InOrderSaveReqDto
     * @param buyerInfoVao 购买者信息 值对象
     * @return {@link InOrderSaveReqDto}
     * @author Jxin     
     */
    public static InOrderSaveReqDto convertToInOrderSaveReqDto(BuyerInfoVao buyerInfoVao) {
        Assert.notNull(buyerInfoVao, "buyerInfoVao不能为null");

        final InOrderSaveReqDto result = new InOrderSaveReqDto();

        result.setName(buyerInfoVao.getName());
        result.setComment(buyerInfoVao.getComment());
        result.setPhone(buyerInfoVao.getPhone());
        result.setProvince(buyerInfoVao.getProvince());
        result.setCity(buyerInfoVao.getCity());
        result.setArea(buyerInfoVao.getArea());
        result.setStreet(buyerInfoVao.getStreet());
        result.setAddress(buyerInfoVao.getAddress());

        return result;
    }
}
